/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InternalFrame_Kendaraan.java
 *
 * Created on Nov 23, 2011, 7:32:50 PM
 */
package Boundaries;

import Controller.Add_Controller;
import Entities.Kendaraan;
import TableModel.Kendaraan_List;
import TableModel.Kendaraan_List_TableModel;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Adrian
 */
public class InternalFrame_Kendaraan extends javax.swing.JInternalFrame {

    /** Creates new form InternalFrame_Kendaraan */
    public InternalFrame_Kendaraan() {
        try {
            initComponents();
            List<Kendaraan> kendaraans = Kendaraan_List.getKendaraanList().getAllKendaraan();
            Kendaraan_List_TableModel kendaraan_table = new Kendaraan_List_TableModel(kendaraans);
            jTable1.setModel(kendaraan_table);
        } catch (SQLException ex) {
            Logger.getLogger(InternalFrame_Kendaraan.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        tf_Kendaraan_NoPolisi = new javax.swing.JTextField();
        comboBox_Kendaraan_TipeKendaraan = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        tf_Kendaraan_WarnaKendaraan = new javax.swing.JTextField();
        jScrollPane5 = new javax.swing.JScrollPane();
        ta_Kendaraan_SpesifikasiKendaraan = new javax.swing.JTextArea();
        jLabel6 = new javax.swing.JLabel();
        button_Kendaraan_Batal = new javax.swing.JButton();
        button_Kendaraan_Tambah = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        tf_Kendaraan_MerkKend = new javax.swing.JTextField();
        label_harga_sewa_per_hari = new javax.swing.JLabel();
        tf_harga_sewa_per_hari = new javax.swing.JTextField();

        setPreferredSize(new java.awt.Dimension(1010, 480));
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Boundaries/parkir mobil.jpg"))); // NOI18N
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 1000, -1));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        jPanel2.setBackground(new java.awt.Color(204, 204, 255));
        jPanel2.setLayout(null);

        jLabel2.setText("No Polisi");
        jPanel2.add(jLabel2);
        jLabel2.setBounds(10, 31, 90, 14);

        jLabel3.setText("Merk Kendaraan");
        jPanel2.add(jLabel3);
        jLabel3.setBounds(10, 50, 110, 14);
        jPanel2.add(tf_Kendaraan_NoPolisi);
        tf_Kendaraan_NoPolisi.setBounds(140, 28, 120, 20);

        comboBox_Kendaraan_TipeKendaraan.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sedan", "MPV", "SUV", "City Car" }));
        comboBox_Kendaraan_TipeKendaraan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboBox_Kendaraan_TipeKendaraanActionPerformed(evt);
            }
        });
        jPanel2.add(comboBox_Kendaraan_TipeKendaraan);
        comboBox_Kendaraan_TipeKendaraan.setBounds(140, 80, 70, 20);

        jLabel4.setText("Tipe Kendaraan");
        jPanel2.add(jLabel4);
        jLabel4.setBounds(10, 83, 110, 14);

        jLabel5.setText("Warna Kendaraan");
        jPanel2.add(jLabel5);
        jLabel5.setBounds(10, 125, 130, 14);
        jPanel2.add(tf_Kendaraan_WarnaKendaraan);
        tf_Kendaraan_WarnaKendaraan.setBounds(140, 120, 123, 20);

        ta_Kendaraan_SpesifikasiKendaraan.setColumns(20);
        ta_Kendaraan_SpesifikasiKendaraan.setRows(5);
        jScrollPane5.setViewportView(ta_Kendaraan_SpesifikasiKendaraan);

        jPanel2.add(jScrollPane5);
        jScrollPane5.setBounds(140, 150, 200, 80);

        jLabel6.setText("Spefisikasi Kendaraan");
        jPanel2.add(jLabel6);
        jLabel6.setBounds(10, 176, 140, 14);

        button_Kendaraan_Batal.setText("Batal");
        button_Kendaraan_Batal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_Kendaraan_BatalActionPerformed(evt);
            }
        });
        jPanel2.add(button_Kendaraan_Batal);
        button_Kendaraan_Batal.setBounds(210, 320, 80, 23);

        button_Kendaraan_Tambah.setText("Tambah");
        button_Kendaraan_Tambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_Kendaraan_TambahActionPerformed(evt);
            }
        });
        jPanel2.add(button_Kendaraan_Tambah);
        button_Kendaraan_Tambah.setBounds(50, 320, 80, 23);
        jPanel2.add(jSeparator1);
        jSeparator1.setBounds(10, 110, 310, 2);

        jPanel3.setBackground(new java.awt.Color(204, 204, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Table Kendaraan"));

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "No Polisi", "Merk Kend", "Tipe Kend", "Warna Kend", "Spesifikasi", "Status Kend", "Harga"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setResizable(false);
        jTable1.getColumnModel().getColumn(1).setResizable(false);
        jTable1.getColumnModel().getColumn(2).setResizable(false);
        jTable1.getColumnModel().getColumn(3).setResizable(false);
        jTable1.getColumnModel().getColumn(4).setResizable(false);
        jTable1.getColumnModel().getColumn(5).setResizable(false);
        jTable1.getColumnModel().getColumn(6).setResizable(false);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel2.add(jPanel3);
        jPanel3.setBounds(360, 20, 580, 300);
        jPanel2.add(tf_Kendaraan_MerkKend);
        tf_Kendaraan_MerkKend.setBounds(140, 50, 120, 20);

        label_harga_sewa_per_hari.setText("Harga Sewa Per Hari");
        jPanel2.add(label_harga_sewa_per_hari);
        label_harga_sewa_per_hari.setBounds(10, 240, 110, 14);

        tf_harga_sewa_per_hari.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_harga_sewa_per_hariActionPerformed(evt);
            }
        });
        jPanel2.add(tf_harga_sewa_per_hari);
        tf_harga_sewa_per_hari.setBounds(140, 240, 130, 20);

        getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 100, 1000, 350));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void button_Kendaraan_TambahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_Kendaraan_TambahActionPerformed
        // TODO add your handling code here:
        Add_Controller add_Control = new Add_Controller();
        add_Control.addKendaraan(this);

}//GEN-LAST:event_button_Kendaraan_TambahActionPerformed

    private void comboBox_Kendaraan_TipeKendaraanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboBox_Kendaraan_TipeKendaraanActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboBox_Kendaraan_TipeKendaraanActionPerformed

    private void tf_harga_sewa_per_hariActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_harga_sewa_per_hariActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tf_harga_sewa_per_hariActionPerformed

    private void button_Kendaraan_BatalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_Kendaraan_BatalActionPerformed
        // TODO add your handling code here:
        Add_Controller add_Control = new Add_Controller();
        add_Control.reset(this);
    }//GEN-LAST:event_button_Kendaraan_BatalActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton button_Kendaraan_Batal;
    private javax.swing.JButton button_Kendaraan_Tambah;
    public javax.swing.JComboBox comboBox_Kendaraan_TipeKendaraan;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JSeparator jSeparator1;
    public javax.swing.JTable jTable1;
    private javax.swing.JLabel label_harga_sewa_per_hari;
    public javax.swing.JTextArea ta_Kendaraan_SpesifikasiKendaraan;
    public javax.swing.JTextField tf_Kendaraan_MerkKend;
    public javax.swing.JTextField tf_Kendaraan_NoPolisi;
    public javax.swing.JTextField tf_Kendaraan_WarnaKendaraan;
    public javax.swing.JTextField tf_harga_sewa_per_hari;
    // End of variables declaration//GEN-END:variables
}
